﻿using IDCardValidator.Core;
using System;

namespace IDCardValidator.DemoCore
{
    class Program
    {
        static void Main(string[] args)
        {
            do
            {
                Console.Write("请输入身份证号:");
                string idcard = Console.ReadLine();
                Console.Write("请输入身份证类型(中国大陆1,中国香港2，中国澳门3，中国台湾4):");
                string types = Console.ReadLine();
                bool result = CheckIdcard(idcard, types);
                if (result)
                {
                    Console.WriteLine("通过检验");
                }
                else
                {
                    Console.WriteLine("未通过检验");
                }
                Console.Write("退出输入(exit)");
            } while (Console.ReadLine().ToLower() != "exit");
        }

        private static bool CheckIdcard(string idcard, string types)
        {
            bool flag = false;
            switch (types)
            {
                case "1":
                    flag = Tools.IsIDCard(idcard);
                    break;
                case "2":
                    flag = Tools.IsHKIDCard(idcard);
                    break;
                case "3":
                    flag = Tools.IsMOIDCard(idcard);
                    break;
                case "4":
                    flag = Tools.IsTWIDCard(idcard);
                    break;
            }
            return flag;
        }
    }
}
